-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add AmazonS3Resolver and ResolverInterface::remove #66
Conversation
* move getBrowserPath() from CacheManager into ResolverInterface
ok looks sensible after a first quick skim. need to analyze the refactoring some more. will get to it some time this week. |
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function remove($targetPath, $filter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't this method be moved to AbstractFilesystemResolver
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can; will update it.
add AmazonS3Resolver and ResolverInterface::remove
ok .. i have merged the current state .. see my comment about the remove method though. |
Oh, then I was to late; if this one is fine I'll open another PR: havvg/LiipImagineBundle@46450984 |
yeah .. looks good. |
Nice implementation. I just tested it and all worked fine, but my site slowed down a bit. After some debugging, I found out that the method if_object_exists takes approx. 0.3 seconds. Here is the code I used to test this behavior <?php
require_once __DIR__.'/../vendor/aws-sdk/sdk.class.php';
define("AWS_CERTIFICATE_AUTHORITY", true);
$s3 = new AmazonS3(array('key' => '...', 'secret' => '....'));
$start = microtime(true);
$s3->if_object_exists('my-bucket', 'filename.txt');
$end = microtime(true);
var_dump($end - $start); As you can imagine, this is not a practical solution for a production environment. I still couldn't find another way to check if the image/object already exists. Maybe it should be cached somewhere (database?) that the object exists when the thumb is created. Any suggestion? |
yeah .. the iffy bit is that there is no goto caching bundle for Symfony2 yet .. |
Yeah right. What do you think about implementing a caching layer in this bundle or just an interface which could be used to implement caching for the resolvers? |
seems like choosing a poison :-/ there is LiipDoctrineCacheBundle .. which however could use some love to make it easier to configure stuff like memcache(d). |
Hi, I've just started to use this, and @Spea is correct, is is a bit slow. I'm surprised there is no go-to caching bundle, surely knocking one up wouldn't even be too difficult (could use the doctrine one as an example) - for now as a quickfix and we just use APC? I can't imagine too many sites running with APC disabled (wrap a check around whether or not apc is enabled ofcourse). Cheers. |
I've also just noticed another problem that I'm hoping @havvg may get around to looking into. I am using the SteamLoader you've recently introduced and this s3 resolver and I've run into a bit of a problem, probably partly due to the way I've set it up, but I think someone else it bound to run into the same issue, My gaufrette config:
I'm using one single 'media cache' filesystem, and writing multiple cached copies of images into subdirectories, ie:
This now writes out my images to /web/media/cache/composite/ (I can post up more of my config if you're confused) Now when I use the amazon loader, it attempts to determine if the file is already on s3 inside the getBrowserPath function In this section:
Unfortunately getObjectPath inserts another / into the middle of the $filter and $path
Which returns: When the call if "if object exists" is made, it always return false because of the double slash, then tries writing the file to s3 on every request. The getObjectPath function should check the first char of $path for a /. Cheers. |
One last one, I promise When you make the call to $this->storage->get_object_url($this->bucket, $objectPath) there is one problem. If the user is browsing the site via SSL, you'll be supplying them a URL to an image not served via SSL, although s3 does support ssl. One thing I was thinking is just stripping off 'http:' from the URL and serving '//bucket.amazon' (similar to how jquery is served here: //ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js) that way you don't have to check if the current request is being served via HTTPs) What I did just notice though is that my content is being served via: Weirdly adding https:// to this url, this throws up a bug SSL warning, there is a certficate for '*.s3.amazonaws.com' but my browser doesn't appear to like it, at all (Chrome + FF) If you try: You'll notice that is returns the exact same URL, with https:// prepended to it, the url amazon generates via AWS console is: Can anyone comment on whether or not that SSL cert should have validated in the first place? Or an alternative solution to this issue? p.s: @lsmith77 can we re-open this issue, it feels weird going on inside a closed issue. |
I just remembered there is a note about SSL and Amazon, not sure if related, see: "Amazon S3" on https://github.com/KnpLabs/Gaufrette |
Thank you for all the feedback! I'll open up a hotfix branch for this and apply the feedback to it. |
Has anyone gotten around to looking into caching to mitigate the slowdown caused by |
In addition there is a re-factoring considering the browser path.
I stumbled upon this, while creating the resolver. The browser path of this resolver is an external URL. Therefore the
getBrowserPath
has been moved into theResolverInterface
.